package com.everyday.practice.leetCode;

public class Title34 {

    public static void main(String[] args) {
        int[] nums=new int[5];
        nums[0]=1;
        nums[1]=1;
        nums[2]=2;
        nums[3]=3;
        nums[4]=4;
        System.out.println(searchRange(nums,3));
    }

    public static int[] searchRange(int[] nums, int target) {
        int[] result=new int[2];
        int first=-1;
        int last=-1;
        for (int i=0;i<nums.length;i++){
            int num = nums[i];
            if (first==-1&&num==target){
                first=i;
                last=i;
                continue;
            }
            if (last>-1&&num==target){
                last=i;
            }
        }
        result[0]=first;
        result[1]=last;
        return result;
    }
}
